<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CardUser extends Card
{
    protected $table = 'mckj_card_user';

    protected $fillable = [
        'name', 'user_id', 'price', 'status', 'card_id', 'number', 'surplus_number',
        'expiration_time', 'validity_day', 'image_url', 'careful_item', 'mcstation_ids'
    ];

    public function getSurplusNumberHumanAttribute()
    {
        if ($this->surplus_number == -1) {
            return '无限次';
        }
        return $this->surplus_number . "次";
    }

    public function user()
    {
        return $this->belongsTo(User::class, "user_id");
    }

    public function card()
    {
        return $this->belongsTo(Card::class, "card_id");
    }

}
